// pages/public/public.js
Page({

  /**
   * 页面的初始数据
   */
  data: {


  },

  download(e) {
    var content = e.currentTarget.dataset.name
    //console.log("234567",content)
    var u1 = 'http://localhost:8080/parking/picturefile/'
    var url = u1 + content
    console.log(url)
    wx.downloadFile({
      url: url,
      success(res) {
        var filePath = res.tempFilePath
        console.log(res)
        if (res.statusCode === 200) {
          wx.openDocument({
            filePath: filePath,
            success: function () {
              console.log("下载成功")
              wx.showToast({
                title: '下载成功',
                icon: 'success',
                duration: 1000
              })
            }
          })
        }
      },
      fail(res) {
        wx.showToast({
          title: '下载失败，重新下载',
          icon: 'success',
          duration: 200
        })
      }

    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.request({
      url: 'http://localhost:8080/parking/info/wxallinfo',
      success: function (res) {
        console.log("21324565768" + res.data.mess)
        wx.setStorageSync("mess", res.data.mess)
      }
    })
    var that = this
    var pagedata = wx.getStorageSync("mess")
    that.setData({
      me: pagedata
    })

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    wx.request({
      url: 'http://localhost:8080/parking/info/wxallinfo',
      success: function (res) {
        console.log("21324565768" + res.data.mess)
        wx.setStorageSync("mess", res.data.mess)
      }
    })
    var that = this
    var pagedata = wx.getStorageSync("mess")
    that.setData({
      me: pagedata
    })
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})